<template>
  <div id="adminupdatebox">
    <h1>修改信息</h1>
    <el-form label-width="100px">
      <el-form-item label="管理员编号">
        <el-input v-model="addmins._id"></el-input>
      </el-form-item>
      <el-form-item label="管理员用户名">
        <el-input v-model="addmins.username"></el-input>
      </el-form-item>
      <el-form-item label="是否可用">
        <el-switch
          v-model="addmins.isAdmins"
          active-color="#13ce66"
          inactive-color="#ff4949"
        >
        </el-switch>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="changeAdmins(addmins)"
          >确认修改</el-button
        >
        <el-button @click="$router.push('/System/AdminList')">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
  <!-- <div class="adminupdatebox">
    <h1>修改信息</h1>
    <el-table :data="addmins" border style="width: 100%">
      <el-table-column prop="_id" label="管理员编号"> </el-table-column>
      <el-table-column prop="username" label="管理员姓名"> </el-table-column>

      <el-table-column prop="images" label="管理员头像">
        <template slot-scope="scope">
          <el-image
            style="width: 60px; height: 60px"
            :src="'http://localhost:3000/images/' + scope.row.images"
          ></el-image>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button
            @click="handleEdit(scope.$index, scope.row._id)"
            type="text"
            size="small"
            >确认修改</el-button
          >
          <el-button type="text" size="small">禁用</el-button>
          <el-button type="text" size="small">取消禁用</el-button>
          <el-button type="text" size="small">取消</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div> -->
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("admins");
export default {
  data() {
    return {
      addmins: {},
    };
  },
  computed: {
    ...mapState(["adminData"]),
  },
  methods: {
    ...mapActions(["getOneAdmin", "changeAdmins"]),
  },
  created() {
    // console.log(this.getOneAdmin);
    this.getOneAdmin(this.$route.params.id);
    // console.log(this.$route.params.id,121);
    this.addmins = this.adminData;
    // console.log(this.addmins,12345);
  },
  watch: {
    adminData: {
      handler() {
        this.addmins = this.adminData[0];
        // console.log(this.addmins, "addmins");
      },
    },
  },
};
</script>

<style lang="scss">
.el-input__inner {
  width: 200px;
}
</style>